package cn.iocoder.yudao.module.member.dal.mysql.memberconf.confadditionalfee;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.confadditionalfee.vo.MemberConfAdditionalFeePageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.confadditionalfee.MemberConfAdditionalFeeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 阶梯费用配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MemberConfAdditionalFeeMapper extends BaseMapperX<MemberConfAdditionalFeeDO> {

    default PageResult<MemberConfAdditionalFeeDO> selectPage(MemberConfAdditionalFeePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberConfAdditionalFeeDO>()
                .eqIfPresent(MemberConfAdditionalFeeDO::getMaterialPolicyId, reqVO.getMaterialPolicyId())
                .eqIfPresent(MemberConfAdditionalFeeDO::getMinWeight, reqVO.getMinWeight())
                .eqIfPresent(MemberConfAdditionalFeeDO::getMaxWeight, reqVO.getMaxWeight())
                .eqIfPresent(MemberConfAdditionalFeeDO::getFeePerGram, reqVO.getFeePerGram())
                .orderByDesc(MemberConfAdditionalFeeDO::getId));
    }

    default List<MemberConfAdditionalFeeDO> selectListByMaterialPolicyId(Long materialPolicyId) {
        return selectList(MemberConfAdditionalFeeDO::getMaterialPolicyId, materialPolicyId);
    }

    default List<MemberConfAdditionalFeeDO> selectListByMaterialPolicyIds(List<Long> materialPolicyIds) {
        return selectList(new LambdaQueryWrapperX<MemberConfAdditionalFeeDO>()
                .in(MemberConfAdditionalFeeDO::getMaterialPolicyId, materialPolicyIds));
    }

    default int deleteByMaterialPolicyId(Long materialPolicyId) {
        return delete(MemberConfAdditionalFeeDO::getMaterialPolicyId, materialPolicyId);
    }

}